package com.oa.admin.service.impl;

import com.joneying.common.annotation.CommonService;
import com.oa.admin.dto.FinancialRemindListDTO;
import com.oa.admin.vo.FinancialRemindListVO;
import com.oa.core.PageResult;
import com.oa.admin.entity.FinancialRemind;
import com.oa.admin.mapper.FinancialRemindMapper;
import com.oa.admin.service.IFinancialRemindService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.plugins.Page;
import java.util.List;

/**
 * <p>
 * 财务事项提醒 服务实现类
 * </p>
 *
 * @author syb123
 * @since 2019-01-22
 */
@Service
public class FinancialRemindServiceImpl extends ServiceImpl<FinancialRemindMapper, FinancialRemind> implements IFinancialRemindService {

    private final FinancialRemindMapper financialRemindMapper;

    @Autowired
    public FinancialRemindServiceImpl(FinancialRemindMapper financialRemindMapper) {
        this.financialRemindMapper = financialRemindMapper;
    }

    @Override
    @CommonService
    public PageResult<FinancialRemind> findList(Integer pageNum, Integer pageSize) {
        if(pageNum == null){
            List<FinancialRemind> list = financialRemindMapper.findList();
            return new PageResult<>(list);
        }else{
            // 当前页，总条数 构造 page 对象
            Page<FinancialRemind> page = new Page<>(pageNum, pageSize);
            //查询
            List<FinancialRemind> list = financialRemindMapper.findList(page);
            return new PageResult<>(list);
        }
    }

    /**
    * 根据id查询
    */
    @Override
    @CommonService
    public FinancialRemind findFinancialRemindById(String id){
        return financialRemindMapper.findById(id);
    }

    @Override
    public PageResult<FinancialRemindListVO> findFinancialRemindList(FinancialRemindListDTO financialRemindListDTO) {
        Page page = financialRemindListDTO.getPage();
        return new PageResult<>(financialRemindMapper.findFinancialRemindList(page, financialRemindListDTO));
    }
}
